using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace GameEditor.Common.Controls
{
    public class TextButton : TextBox
    {

        private Button button;

        public event EventHandler ButtonClicked = delegate { };

        public TextButton()
        {
            SetStyle(ControlStyles.ContainerControl, true);
            button = new Button();
            this.Controls.Add(button);
            button.Cursor = Cursors.Arrow;
            button.Width = 35;
            button.Text = "...";
            button.Click += new EventHandler(button_Click);

            UpdateButtonLayout();
        }

        public int ButtonWidth
        {
            get { return button.Width; }
            set { button.Width = value; }
        }

        public string ButtonText
        {
            get { return button.Text; }
            set { button.Text = value; }
        }



        void button_Click(object sender, EventArgs e)
        {
            ButtonClicked(this, e);
        }
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            UpdateButtonLayout();
        }
        void UpdateButtonLayout()
        {
            button.Location = new Point(Width - button.Width - 3, -1);
            button.Height = Height - 2;
        }

    }
}
